function Vec2(a, b){
	this.a = a;
	this.b = b;
	
	this.length = -1;
}

Vec2.prototype.equals = function(a, b){
	if (arguments.length == 1){
		return (this.a == a.a && this.b == a.b);
	}else if (arguments.length == 2){
		return (this.a == a && this.b == b);
	}
	
	return false;
};

Vec2.prototype.set = function(a, b){
	if (arguments.length == 1){
		this.a = a.a;
		this.b = a.b;
	}else if (arguments.length == 2){
		this.a = a;
		this.b = b;
	}
};

Vec2.prototype.sum = function(a, b){
	if (arguments.length == 1){
		this.a += a.a;
		this.b += a.b;
		this.length = -1;
	}else if (arguments.length == 2){
		this.a += a;
		this.b += b;
		this.length = -1;
	}
};

Vec2.prototype.mult = function(a){
	this.a *= a;
	this.b *= a;
	this.length = -1;
};

Vec2.prototype.getLength = function(){
	if (this.length != -1) return this.length;
	
	this.length = Math.sqrt(Math.pow(this.a, 2) + Math.pow(this.b, 2));
	return this.length;
};

Vec2.prototype.getDistance = function(/*vec2*/ vector){
	var a = Math.abs(this.a - vector.a);
	var b = Math.abs(this.b - vector.b);
	
	return Math.sqrt(a*a + b*b);
};
Vec2.prototype.clone = function(){
	return vec2(this.a, this.b);
};

function vec2(a, b){
	return new Vec2(a, b);
}